<template>
  <div>
    <h1>房号添加</h1>
    <table class="table table-borsered">
      <tbody>
        <tr>
          <td>房号</td>
          <td>
            <input type="text" v-model="info.scode" />
          </td>
        </tr>
        <tr>
          <td>名称</td>
          <td><input type="text" v-model="info.sname" /></td>
        </tr>
        <tr>
          <td>创建人</td>
          <td><input type="text" v-model="info.create" /></td>
        </tr>
        <tr>
          <td></td>
          <td>
            <input type="button" value="添加" @click="add" />
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { reactive } from "vue";
let info: any = reactive({
  sid: 0,
  scode: "",
  sname: "",
  stype: 1,
  create: "",
});
const add = () => {
  if (info.scode != "") {
    alert("房号不能为空");
    return;
  }
  if (info.sname != "") {
    alert("名称不能为空");
    return;
  }
  if (info.create != "") {
    alert("创建人不能为空");
    return;
  }
  axios({
    url: "/api/Sto/AddSto",
    method: "post",
    data: info,
  }).then((res) => {
    console.log(res);
    if (res.data == -1) {
      alert("房号重复");
      return;
    }
    if (res.data > 0) {
      alert("添加成功");
      return;
    } else {
      alert("添加失败");
      return;
    }
  });
};
</script>

<style scoped></style>
